// pages/teacher/student/index.js
import {
  student
} from "../../../api/teacher";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    banjiId: String
  },
  data: {
    arr: {},
    refreshing: false,
    pageNo: 1,
    pageSize: 10,
  },
  observers: {
    banjiId: function (value) {
      if (value == undefined) return
      this.loadData()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    loadData: function () {
      let data = {
        banjiid: this.data.banjiId,
        pageNo: this.data.pageNo,
        pageSize: this.data.pageSize
      }
      student(data).then(res => {
        // console.log("okkk", res)
        let arr = res
        // console.log("res.arr",arr)
        this.setData({
          arr: arr,
          refreshing: false,
          loadMore: res.length == this.data.pageSize
        })
      })
    },

    //下拉刷新
    onRefresh: function () {
      this.setData({
        pageNo: 1,
        arr: []
      })
      this.loadData()
    },

    //上拉加载（分页）
    onMore: function () {
      if (this.data.loadMore === false) return
      let pageNo = this.data.pageNo
      pageNo++
      this.setData({
        pageNo
      })
      this.loadData()
    },

  }
})